<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
<script>
    window.onload = () => {
        const OBox = document.querySelector('#box')
        const zhanFileUrl = 'http://iwenwiki.com/api/vue3-image/create-vue3-2.png'
        const fileUrl = 'http://iwenwiki.com/api/vue3-image/create-vue3-10.png'
        function loadImage(fileUrl, resolve, reject) {
            const img = new Image()
            img.src = fileUrl
            img.onload = () => {
                resolve('获取图片成功')
                OBox.appendChild(img)
            }
            img.onerror =(err) => {
                loadImage(zhanFileUrl,data=>{
                    console.log(data)
                }, err => {
                    console.log(err)
                })
                reject(err)
            }
        }
        loadImage(fileUrl,data => {
            console.log(data)
        }, err => {
            console.log(err)
        })
    }
</script>
</head>
<body>
<div id="box"></div>
</body>
</html>
